//
//  CaiPuMaterialCollectionViewCell.m
//  KCZ_B段项目
//
//  Created by dllo on 15/11/6.
//  Copyright © 2015年 Sky. All rights reserved.
//

#import "CaiPuMaterialCollectionViewCell.h"
#import <UIImageView+WebCache.h>
#import "FontSizeSingleTon.h"
#define Font [[FontSizeSingleTon shareFontSize]array]
#import "Adaptive.h"
#import "FitHeader.h"
@implementation CaiPuMaterialCollectionViewCell
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self createCell];
    }
    return self;
}
-(void)createCell
{
    _imageView = [[UIImageView alloc]init];
    [self.contentView addSubview:_imageView];
    
    _contentLable = [[UILabel alloc]init];
    _contentLable.numberOfLines = 0;
    _contentLable.font = [UIFont systemFontOfSize:[Font[1] integerValue]];
    [self.contentView addSubview:_contentLable];
    
    _effectTitleLable = [[UILabel alloc]init];
    _effectTitleLable.textColor = [UIColor colorWithRed:0.42 green:0.58 blue:0 alpha:1];
    _effectTitleLable.font = [UIFont systemFontOfSize:[Font[0] integerValue]];
    [self.contentView addSubview:_effectTitleLable];
    
    _effectLable = [[UILabel alloc]init];
    _effectLable.numberOfLines = 0;
    _effectLable.font = [UIFont systemFontOfSize:[Font[1] integerValue]];
    [self.contentView addSubview:_effectLable];
    
    _pickTitleLable = [[UILabel alloc]init];
    _pickTitleLable.textColor = [UIColor colorWithRed:0.42 green:0.58 blue:0 alpha:1];
    _pickTitleLable.font = [UIFont systemFontOfSize:[Font[0] integerValue]];;
    [self.contentView addSubview:_pickTitleLable];
    
    _pickLable = [[UILabel alloc]init];
    _pickLable.numberOfLines = 0;
    _pickLable.font = [UIFont systemFontOfSize:[Font[1] integerValue]];
    [self.contentView addSubview:_pickLable];
}

-(void)setMaterialModel:(ZJHCaiPuMaterialModel *)materialModel
{
    [_imageView sd_setImageWithURL:[NSURL URLWithString:materialModel.Cover] placeholderImage:[UIImage imageNamed:@"8080"]];
    _contentLable.text = materialModel.Content;
    _effectTitleLable.text = [NSString stringWithFormat:@"%@的功效和作用", materialModel.Name];
    _effectLable.text = materialModel.Effect;
    _pickTitleLable.text = [NSString stringWithFormat:@"如何挑选%@", materialModel.Name];
    _pickLable.text = materialModel.Pick;
    
    _imageView.frame = CGRectMake(10 * wt, 20 * ht, 50 * wt, 50 * ht);
    CGFloat contentLableHeight = [Adaptive adaptiveHeightByString:_contentLable.text Width:295 * wt FontSize:[Font[1] integerValue]];
    _contentLable.frame = CGRectMake(_imageView.frame.origin.x + _imageView.frame.size.width + 10 * wt, _imageView.frame.origin.y, 295 * wt, contentLableHeight);
    _effectTitleLable.frame = CGRectMake(_imageView.frame.origin.x, _contentLable.frame.origin.y + _contentLable.frame.size.height + 20 * ht, 200 * wt, 20 * ht);
    CGFloat effectLableHeight = [Adaptive adaptiveHeightByString:_effectLable.text Width:350 * wt FontSize:[Font[1] integerValue]];
    _effectLable.frame = CGRectMake(_effectTitleLable.frame.origin.x, _effectTitleLable.frame.origin.y + _effectTitleLable.frame.size.height + 10 * ht, 350 * wt, effectLableHeight);
    _pickTitleLable.frame = CGRectMake(_effectLable.frame.origin.x, _effectLable.frame.origin.y + _effectLable.frame.size.height + 20 * ht, 200 * wt, 20 * ht);
    CGFloat pickLableHeight = [Adaptive adaptiveHeightByString:_pickLable.text Width:350 * wt FontSize:[Font[1] integerValue]];
    _pickLable.frame = CGRectMake(_pickTitleLable.frame.origin.x, _pickTitleLable.frame.origin.y + _pickTitleLable.frame.size.height + 10 * ht, 350 * wt, pickLableHeight);
}
@end
